// 引入count - ui
import CountUI from '../../components/Count3'

import { createIncreamentAction, createDecreamentAction, createIncreamentAsyncAction } from '../../redux/count_action'
//引入connect用于连接UI和redux
import { connect } from 'react-redux'
// mapStateToProps 函数的返回值为转态 对象 传递给UI 传递状态
const mapStateToProps = (state) => {
  return {
    count: state
  }
}
// mapDispathcToProps函数 操作状态的方法
const mapDispathcToProps = (dispatch) => {
  return {
    increament: (number) => {
      dispatch(createIncreamentAction(number))
    },
    decreament: number => dispatch(createDecreamentAction(number)),
    increamentAsync: (number, time) => {
      dispatch(createIncreamentAsyncAction(number, time))
    }
  }
}

// 创建并暴露一个 Count的容器组件
const CountContainer = connect(mapStateToProps, mapDispathcToProps)(CountUI)

export default CountContainer

